﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed), ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class InboundDetailService : IInboundDetailService
    {
        public string AutoPutAway(string receiptID, List<string> receiptLineID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).AutoPutAway(receiptID, receiptLineID);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_AutoPutAway_Receipt", receiptID, receiptLineID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string BatchReceiving(string receiptID, List<string> receiptLineID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).BatchReceiving(receiptID, receiptLineID);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_BatchReceiving_Receipt", receiptID, receiptLineID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string CheckSkuIDExist(string orderID, string skuID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ReceiptDetailBLL(pubParasInfo).CheckSkuIDExist(orderID, skuID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return temp;
        }

        public string ConfirmPutAway(List<PutawayDetailInfo> putawayDetailInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).ConfirmPutAway(putawayDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_ConfirmPutAway_Receipt", putawayDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string DeleteReceiptDetailInfo(List<string> receiptID, List<string> receiptLineID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).DeleteReceiptDetail(receiptID, receiptLineID);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_Delete_Receipt", receiptID, receiptLineID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string ExecuteReceiving(ReceiptDetailInfo receiptDetailInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).ExecuteReceiving(receiptDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_Receiving_Receipt", receiptDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string ExecuteReceivingAll(string receiptID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).ExecuteReceivingAll(receiptID);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_ReceivingAll_Receipt", receiptID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string GenPutAway(List<ReceiptPutawayInfo> receiptPutawayInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).GeneratePutAway(receiptPutawayInfo);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_GenPutAway_Receipt", receiptPutawayInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public DataSet GetAllReceiptDetailInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetAllReceiptDetail();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public ReceiptDetailInfo GetNextUncompletedReceiptDetailInfo(string receiptID, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetNextUncompletedReceiptDetailInfo(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public List<ReceiptPutawayInfo> GetPendingPutAwayTaskByTransID(string transID, PubParasInfo pubParasInfo)
        {
            List<ReceiptPutawayInfo> receiptPutAwayInfo = null;
            try
            {
                receiptPutAwayInfo = new ReceiptDetailBLL(pubParasInfo).GetPendingPutAwayTaskByTransID(transID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return receiptPutAwayInfo;
        }

        public DataSet GetPutAwayDetailByPagerQueryEntity(PutawayDetailQueryEntity putawayDetailQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetPutAwayDetailByPagerQueryEntity(putawayDetailQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public ReceiptDetailInfo GetReceiptDetailInfoByID(string receiptID, string receiptLineID, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetReceiptDetailInfoByID(receiptID, receiptLineID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public DataSet GetReceiptDetailInfoByPagerQueryEntity(ReceiptDetailQueryEntity receiptDetailQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetReceiptDetailInfoByPagerQueryEntity(receiptDetailQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public DataSet GetReceiptDetailInfoByQueryEntity(ReceiptDetailQueryEntity receiptDetailQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetReceiptDetailInfoByQueryEntity(receiptDetailQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public List<ReceiptDetailInfo> GetReceiptDetailInfoListByID(string receiptID, PubParasInfo pubParasInfo)
        {
            List<ReceiptDetailInfo> receiptDetailInfos = new List<ReceiptDetailInfo>();
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetReceiptDetailInfoListByID(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return receiptDetailInfos;
        }

        public DataSet GetReceiptHistoryByPagerQueryEntity(ReceiptHistoryQueryEntity receiptHistoryQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailLpnBLL receiptDetailLpnBll = new ReceiptDetailLpnBLL(pubParasInfo);
                return receiptDetailLpnBll.GetReceiptHistoryByPagerQueryEntity(receiptHistoryQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public DataSet GetReceiptInquiryInfoByQueryEntity(ReceiptDetailQueryEntity receiptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ReceiptDetailBLL receiptDetailBll = new ReceiptDetailBLL(pubParasInfo);
                return receiptDetailBll.GetReceiptInquiryInfoByQueryEntity(receiptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return null;
        }

        public List<string> GetUnPrintPutawayTaskIDByReceiptID(string receiptID, PubParasInfo pubParasInfo)
        {
            List<string> result = new List<string>();
            try
            {
                result = new ReceiptDetailBLL(pubParasInfo).GetUnPrintPutawayTaskIDByReceiptID(receiptID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return result;
        }

        public string InsertReceiptDetailInfo(ReceiptDetailInfo receiptDetailInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).InsertReceiptDetail(receiptDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_Insert_Receipt", receiptDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string ReceiptDetailPriceChanges(string receiptID, string lineID, string IsPalletized, float price, float totalPrice, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).ReceiptDetailPriceChanges(receiptID, lineID, IsPalletized, price, totalPrice);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }

        public string UpdateReceiptDetailInfo(ReceiptDetailInfo receiptDetailInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                returnStr = new ReceiptDetailBLL(pubParasInfo).UpdateReceiptDetail(receiptDetailInfo);
                new OperationLogBLL(pubParasInfo).Insert("InboundDetailService_Update_Receipt", receiptDetailInfo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "InboundDetailService异常");
            }
            return returnStr;
        }
    }
}

